package cn.ld.module.infra.dal.mapper.job;

import cn.ld.framework.common.pojo.PageResult;
import cn.ld.framework.mybatis.core.mapper.BaseMapperX;
import cn.ld.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.ld.module.infra.controller.admin.job.vo.job.JobPageInVO;
import cn.ld.module.infra.dal.entity.job.JobEntity;
import org.apache.ibatis.annotations.Mapper;

/**
 * 定时任务 Mapper
 *
 * @author 蓝盾
 */
@Mapper
public interface JobMapper extends BaseMapperX<JobEntity> {

    default JobEntity selectByHandlerName(String handlerName) {
        return selectOne(JobEntity::getHandlerName, handlerName);
    }

    default PageResult<JobEntity> selectPage(JobPageInVO inVO) {
        return selectPage(inVO, new LambdaQueryWrapperX<JobEntity>()
                .likeIfPresent(JobEntity::getName, inVO.getName())
                .eqIfPresent(JobEntity::getStatus, inVO.getStatus())
                .likeIfPresent(JobEntity::getHandlerName, inVO.getHandlerName())
        );
    }

}
